package sphere.view;

import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.Panel;
import java.awt.TextField;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import sphere.controller.SphereController;

public class SphereWindow extends Frame {
	
	Panel p;
	Label radius , volume, surfaceArea; 
	TextField radiusT, volumeT, surfaceAreaT;
	
	protected class PrivListener extends WindowAdapter 
	{
		public void windowClosing (WindowEvent e )
		{
			System.exit(0) ;
		}
	}
	
	public SphereWindow (String titre)
	{
		super(titre);
		PrivListener monListener = new PrivListener();
		this.addWindowListener(monListener);
		
		this.setLayout(new FlowLayout());
		this.p = new Panel();
		this.p.setLayout(new GridLayout(3,2,10,10));
		
		this.radius=new Label("Radius =");
		this.p.add(this.radius);
		this.radiusT= new TextField();
		SphereController monListener2 = new SphereController(this);
		this.radiusT.addTextListener(monListener2);
		this.p.add(this.radiusT);
		
		this.volume=new Label("Volume =");
		this.p.add(this.volume);
		this.volumeT= new TextField();
		this.p.add(this.volumeT);
		
		this.surfaceArea=new Label("Surface area =");
		this.p.add(this.surfaceArea);
		this.surfaceAreaT= new TextField();
		this.p.add(this.surfaceAreaT);
		
		this.add(p);
		this.setResizable(false);
		this.pack();
		this.setVisible(true);
		
		
		
	}


	public void setVolumeT(String volumeT) {
		this.volumeT.setText(volumeT);
	}


	public void setSurfaceAreaT(String surfaceAreaT) {
		this.surfaceAreaT.setText(surfaceAreaT);
	}
	
	

}
